home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 46.4 KB | 1,396 lines | [TEXT/MPS ] |
- // UDialog.h
- // Copyright © 1988-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UDIALOG__
- #define __UDIALOG__
-
- // MacApp
-
- #ifndef __UCOMMAND__
- #include "UCommand.h"
- #endif
-
- #ifndef __UCONTROL__
- #include "UControl.h"
- #endif
-
- #ifndef __UGEOMETRY__
- #include "UGeometry.h"
- #endif
-
- #ifndef __UTEVIEW__
- #include "UTEView.h"
- #endif
-
- // Toolbox
-
- #ifndef __ICONS__
- #include <Icons.h>
- #endif
-
- //----------------------------------------------------------------------------------------
- // Forward and external class declarations.
- //----------------------------------------------------------------------------------------
-
- class TAssociation;
- class TDocument;
- class TTEView;
- class TScroller;
- class TToolboxEvent;
- class TEditText;
- class TDialogTEView;
-
-
- //----------------------------------------------------------------------------------------
- // Some constants
- //----------------------------------------------------------------------------------------
-
- const Boolean kPreferColor = TRUE; // argument to IIcon
-
- const Boolean kControlOn = TRUE; // argument to ICheckBox and IRadio
-
- const short kMaxTEWidth = 688; // Maximum width for TEditText autoscroll
-
- const ResNumber phInvalidValue = 300; // Alert used when an invalid value is
- // entered
-
- const ResNumber kDialogTEViewID = 300; // The ID of the 'view' resource for the
- // "floating" TEView
-
- const ResNumber kInvalidValueReasons = 300; // CString list used for invalid value
- // alert
-
- const short kErrorHandled = -1; // Don't post an alert, the user handled
- // it
-
- const long kValidValue = 0; // Not looked up in the CString list.
-
- const long kInvalidValue = 1;
-
- const long kValueTooSmall = 2;
-
- const long kValueTooLarge = 3;
-
- const long kNonNumericCharacters = 4;
-
- const long kTooManyCharacters = 5;
-
- const long kNoOfDefaultReasons = 5;
-
-
- //----------------------------------------------------------------------------------------
- // TDialogView: Installs a TDialogBehavior in the window
- //----------------------------------------------------------------------------------------
-
- class TDialogView : public TView
- {
- MA_DECLARE_CLASS;
-
- public:
- TDialogView();
- // Constructor
- virtual ~TDialogView();
- // Destructor
-
- void IDialogView(TDocument* itsDocument,
- TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- IDType itsDefItemID,
- IDType itsCancelItemID);
- // Initialization method for TDialogView.
-
- virtual void DoPostCreate(TDocument* itsDocument); // Override
- // Overridden to install a TDialogBehavior in the window , if necessary,
- // and set its attributes (default item and cancel item)
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- IDType fDefaultItem; // The identifier of the default item
-
- IDType fCancelItem; // The identifier of item that cancels
- // dialog
- };
-
-
- //----------------------------------------------------------------------------------------
- // TButton: Mimics a typical toolbox button as used in a dialog.
- //----------------------------------------------------------------------------------------
-
- class TButton : public TCtlMgr
- {
- MA_DECLARE_CLASS;
-
- public:
- TButton();
- // Constructor
- virtual ~TButton();
- // Destructor
-
- void IButton(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- const CStr255& itsLabel);
- // Initializes the button setting the fDefaultChoice field to mButtonHit.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
-
- virtual void DoEvent(EventNumber eventNumber,
- TEventHandler* source,
- TEvent* event);
- // If the hit is mButtonHit then flash the button provided you didn't hit
- // yourself.
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- ResNumber fStrListID; // button's label: STR# rsrc id
-
- short fIndex; // index into STR#
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TCheckBox: Provides the functionality of a toolbox checkbox.
- //----------------------------------------------------------------------------------------
-
- class TCheckBox : public TCtlMgr
- {
- MA_DECLARE_CLASS;
-
- public:
- TCheckBox();
- // Constructor
- virtual ~TCheckBox();
- // Destructor
-
- void ICheckBox(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- const CStr255& itsLabel,
- Boolean isTurnedOn);
- // Initialize the checkbox setting fDefaultChoice to mCheckBoxHit.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
-
- virtual void DoEvent(EventNumber eventNumber,
- TEventHandler* source,
- TEvent* event);
- // If the hit is mCheckBoxHit then toggle the checkbox.
-
- virtual Boolean IsOn();
- // Is the checkbox currently checked.
-
- virtual void SetState(Boolean state, Boolean redraw);
- // Sets the state of the checkbox to state and if redraw is true redraws it.
-
- virtual void Toggle(Boolean redraw);
- // Toggles the state of the checkbox redraw it if redraw is true.
-
- virtual void ToggleIf(Boolean matchState, Boolean redraw);
- // Toggles the state of the checkbox if matchState is true redrawing if redraw is
- // true.
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- ResNumber fStrListID; // check box's label: STR# rsrc id
-
- short fIndex; // index into STR#
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TRadio: Provides the functionality of a toolbox radio button.
- //----------------------------------------------------------------------------------------
-
- class TRadio : public TCtlMgr
- {
- MA_DECLARE_CLASS;
-
- public:
- TRadio();
- // Constructor
- virtual ~TRadio();
- // Destructor
-
- void IRadio(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- const CStr255& itsLabel,
- Boolean isTurnedOn);
- // Initalize the radio button procedurally.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
- virtual void DoPostCreate(TDocument* itsDocument); // Override
- // Calls HandleEvent(mRadioHit…) if the radio is on so a cluster can synch up
-
- virtual void DoEvent(EventNumber eventNumber,
- TEventHandler* source,
- TEvent* event);
- // If the hit is mRadioHit then toggle the radio button.
-
- virtual Boolean IsOn();
- // Is the radio button currently on.
-
- virtual void SetState(Boolean state, Boolean redraw);
- // Sets the state of the radio button to state, redrawing if redraw is true.
-
- virtual void Toggle(Boolean redraw);
- // Toggles the state of the radio button, redrawing if redraw is true.
-
- virtual void ToggleIf(Boolean matchState, Boolean redraw);
- // Only toggles the state of the radio button if matchState is true, redrawing if
- // redraw is true.
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- ResNumber fStrListID; // radio's label: STR# rsrc id
-
- short fIndex; // index into STR#
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TCluster: Provides a mechanism whereby radio buttons can be grouped in clusters, such
- // that when one of the buttons is selected the others are all deselected. Also can be
- // utilized for providing labelled adornments around groups of dialog items.
- //----------------------------------------------------------------------------------------
-
- class TCluster : public TControl
- {
- MA_DECLARE_CLASS;
-
- public:
- TCluster();
- // Constructor
-
- void ICluster(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- ResNumber itsRsrcID,
- short itsIndex);
- // Initialize the cluster procedurally.
-
- virtual TObject* Clone();
- // Calls Inherited::Clone and then clones owned objects.
-
- virtual ~TCluster();
- // Release the label and call Inherited::Free.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
-
- virtual void Draw(const VRect& area);
- // Frame the cluster if there is a label, then draw the label.
-
- virtual void DrawLabel(const VRect& area);
- // Draw the label.
-
- virtual void DoEvent(EventNumber eventNumber,
- TEventHandler* source,
- TEvent* event);
- // Responsible for resetting the radio buttons so that the last selected one is
- // the only one selected.
-
- virtual void GetLabel(CStr255& theLabel);
- // Returns in theLable the text in the clusters label.
-
- virtual void ReleaseLabel();
- // Releases fDataHandle which is a CString handle containing the text for the
- // label.
-
- virtual void SetLabel(const CStr255& theLabel, Boolean redraw);
- // Sets the clusters label to be theLabel, redrawing if redraw is true.
-
- virtual void SetLabelWithStrListID(ResNumber theStrListID, short theIndex, Boolean redraw);
- // Set fDataHandle to the string specified by theStrListID and theIndex and sets fStrListID
- // and fIndex accordingly.
-
- virtual IDType GetCurrentChoice();
- // Returns the ID of the currently selected button
-
- virtual void SetCurrentChoice(IDType newChoice);
- // Highlights the specified button, and turns off all others off
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- CStringHandle fDataHandle; // the cluster's label
- IDType fCurrentChoice; // the ID of the currently selected radio button
-
- ResNumber fStrListID; // STR# rsrc id of the cluster's label
-
- short fIndex; // index into STR#
- };
-
-
- //----------------------------------------------------------------------------------------
- // TIcon: Provides an icon that can behave as a button.
- //----------------------------------------------------------------------------------------
-
- class TIcon : public TControl
- {
- MA_DECLARE_CLASS;
-
- public:
- TIcon();
- // Constructor
-
- virtual ~TIcon();
- // Destructor.
-
- virtual void Free();
- // Release the icon then call Inherited::Free.
-
- void IIcon(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- ResNumber itsRsrcID,
- Boolean preferColor);
- // Initialize the view template.
-
- virtual TObject* Clone();
- // Calls Inherited::Clone and then clones owned objects.
-
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
- //------------------------------------------------------------------------------------
- // Data member accessors.
- //------------------------------------------------------------------------------------
-
- virtual void ReleaseIcon();
- // Releases the handle to the icon.
-
- virtual void SetIcon(Handle theIcon, Boolean redraw);
- // Sets fDataHandle to theIcon, redrawing if redraw is true.
-
- virtual void SetIconRsrcID(ResNumber itsRsrcID, Boolean redraw);
- // setter for fRsrcID
-
- //------------------------------------------------------------------------------------
- // Imaging.
- //------------------------------------------------------------------------------------
-
- virtual void Draw(const VRect& area);
- // Resonsible for drawing the icon and any required adornments.
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- Handle fDataHandle;
-
- ResNumber fRsrcID;
-
- Boolean fPreferColor; // tells us how to GET the icon - GetCIcon
- // or GetIcon
-
- Boolean fIsColor; // tells us how to DRAW or FREE the icon
- };
-
-
- //----------------------------------------------------------------------------------------
- // TIconSuite: Uses System 7 icon utilities to display icons from an icon suite
- //----------------------------------------------------------------------------------------
-
- class TIconSuite : public TIcon
- {
-
- MA_DECLARE_CLASS;
-
- public:
- TIconSuite();
- // Constructor
-
- virtual ~TIconSuite();
-
- virtual void IIconSuite(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- ResNumber itsRsrcID,
- Boolean preferColor);
-
- virtual void ReadFields(TStream* aStream);
-
- virtual IDType GetStandardSignature();
-
- virtual void Draw(const VRect& area);
- // Draw the view.
-
- virtual void GetExtentRegion(RgnHandle itsExtentRgn);
- // Returns the Icon's mask as the region
-
- virtual CRect GetIconRect();
- // return the rect to use when plotting the icon or getting its icon info
-
- virtual void Hilite();
-
- virtual void HiliteState(Boolean state,
- Boolean redraw);
-
- virtual void Dim();
-
- virtual void DimState(Boolean state,
- Boolean redraw);
-
- virtual void ReleaseIcon();
-
- virtual void SetIconRsrcID(ResNumber itsRsrcID,
- Boolean redraw);
-
- protected:
- Boolean fHasSuite; // TRUE if an Icon Suite is loaded (instead of ICON/cicn)
- IconAlignmentType fAlignmentType; // How the icon should be aligned in the view
- IconTransformType fNormalTransform; // How the icon is transformed to display normally
- IconTransformType fHiliteTransform; // How the icon is transformed to display hilited
- IconTransformType fDimTransform; // How the icon is transformed to display dimmed
- };
-
-
- //----------------------------------------------------------------------------------------
- // TSmallIcon
- //----------------------------------------------------------------------------------------
-
- class TSmallIcon : public TControl
- {
- MA_DECLARE_CLASS;
-
- public:
- TSmallIcon();
- // Constructor
- virtual ~TSmallIcon();
- // Destructor
-
- void ISmallIcon(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- ResNumber itsRsrcID);
-
- virtual TObject* Clone();
- // Calls Inherited::Clone and then clones owned objects.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
- //------------------------------------------------------------------------------------
- // Data member accessors.
- //------------------------------------------------------------------------------------
-
- virtual void ReleaseSmallIcon();
-
- virtual void SetSmallIcon(ResNumber theSmallIcon, Boolean redraw);
-
- //------------------------------------------------------------------------------------
- // Imaging.
- //------------------------------------------------------------------------------------
-
- virtual void Draw(const VRect& area);
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- Handle fDataHandle;
-
- ResNumber fRsrcID;
- };
-
-
- //----------------------------------------------------------------------------------------
- // TPattern: Provides an object that can display a pattern and can also behave as a button
- // if required.
- //----------------------------------------------------------------------------------------
-
- class TPattern : public TControl
- {
- MA_DECLARE_CLASS;
-
- public:
- TPattern();
- // Constructor
-
- void IPattern(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- ResNumber itsRsrcID,
- Boolean preferColor);
- // Initialize the pattern procedurally.
-
- virtual TObject* Clone();
- // Calls Inherited::Clone and then clones owned objects.
-
- virtual ~TPattern();
- // Release the pattern then call Inherited::Free.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
- //------------------------------------------------------------------------------------
- // Data member accessors.
- //------------------------------------------------------------------------------------
-
- virtual void ReleasePattern();
- // Releases the pattern by disposing fDataHandle.
-
- virtual void SetPattern(Handle thePattern, Boolean redraw);
- // Sets fDataHandle to thePattern, redrawing if redraw is true.
-
- virtual void SetPatternRsrcID(ResNumber itsRsrcID, Boolean redraw);
- // setter for fRsrcID
-
- //------------------------------------------------------------------------------------
- // Imaging.
- //------------------------------------------------------------------------------------
-
- virtual void Draw(const VRect& area);
- // Responsible for drawing the pattern and any required adornments.
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- Handle fDataHandle;
-
- ResNumber fRsrcID;
-
- Boolean fPreferColor; // tells us how to GET the pattern
-
- Boolean fIsColor; // tells us how to DRAW or FREE the
- // pattern
- };
-
-
- //----------------------------------------------------------------------------------------
- // TPicture: Provides an object that can display a PICT and if required behave like a
- // button.
- //----------------------------------------------------------------------------------------
-
- class TPicture : public TControl
- {
- MA_DECLARE_CLASS;
-
- public:
- TPicture();
- // Constructor
-
- void IPicture(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- ResNumber itsRsrcID);
- // Initialize the picture procedurally.
-
- virtual TObject* Clone();
- // calls Inherited::Clone and then clones owned objects
-
- virtual ~TPicture();
- // Release the picture then call Inherited::Free.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
- //------------------------------------------------------------------------------------
- // Data member accessors.
- //------------------------------------------------------------------------------------
-
- virtual void ReleasePicture();
- // Releases the PICT by disposing of fDataHandle.
-
- virtual void SetPicture(PicHandle thePicture, Boolean redraw);
- // Sets fDataHandle to thePicture, redrawing if redraw is true.
-
- virtual void SetPictureRsrcID(ResNumber itsRsrcID, Boolean redraw);
- // setter for fRsrcID
-
- //------------------------------------------------------------------------------------
- // Imaging.
- //------------------------------------------------------------------------------------
-
- virtual void Draw(const VRect& area);
- // Responsible for drawing the PICT and any required adornments.
-
- //------------------------------------------------------------------------------------
- // Drag & Drop
- //------------------------------------------------------------------------------------
- #if qDrag
-
- virtual Boolean WillDrag(const VPoint& theMouse, const RgnHandle dragCursorRegion);
- // return true if picture content exists, and the view is draggable
-
- virtual void DoAddDragContent();
- // Install PICT flavor data as a promise
-
- virtual Boolean WillAcceptDrop(CDragItemIterator& dragItemIterator);
- // return true if drag is a single item available as a 'PICT'
-
- virtual TCommand* DoMakeDragDropCommand(CommandNumber itsCommandNumber,
- CDragItemIterator& dragItemIterator);
- // Create and return a command that will be posted by the drag session.
-
- virtual void DoFulfillPromise(TDragItem* promisedItem);
- // Provide promised data on demand.
-
- #endif // qDrag
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- PicHandle fDataHandle;
-
- ResNumber fRsrcID;
- };
-
- //----------------------------------------------------------------------------------------
- // TPictureCommand: Command that manages inserting and removing data from a TPicture.
- //----------------------------------------------------------------------------------------
-
- class TPictureCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TPictureCommand();
- // Constructor
-
- void IPictureCommand(ResNumber newRsrcID, PicHandle newPicHandle,
- TPicture* itsPictureView, CommandNumber itsCommandNumber,
- TCommandHandler* itsContext, Boolean canUndo, Boolean causesChange,
- TObject* objectToNotify);
-
- virtual ~TPictureCommand();
-
- virtual void DoIt();
-
- virtual void UndoIt();
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- protected:
- TPicture* fPictureView;
-
- PicHandle fSavedDataHandle;
-
- ResNumber fSavedRsrcID;
- };
-
- //----------------------------------------------------------------------------------------
- // TStaticText: Provides an object that represents a toolbox static text item.
- //----------------------------------------------------------------------------------------
-
- class TStaticText : public TControl
- {
- MA_DECLARE_CLASS;
-
- public:
- TStaticText();
- // Constructor
-
- void IStaticText(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- ResNumber itsRsrcID,
- short itsIndex);
- // Initialize the static text field procedurally.
-
- virtual TObject* Clone();
- // Calls Inherited::Clone and then clones owned objects.
-
- virtual ~TStaticText();
- // Releases the text and then calls Inherited::Free.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
-
- virtual void DoSubstitution(CStr255& theText);
- // Calls ReplaceText so that any paramTxt items can be handled if needed.
-
- virtual void Draw(const VRect& area);
- // Draws the text by calling ImageText.
-
- virtual void GetText(CStr255& theText);
- // If fDataHandle not NULL then returns the text, otherwise returns the NULL
- // CString.
-
- virtual void ImageText(Ptr text,
- long length,
- const VRect& box,
- short just);
- // Draws the text.
-
- virtual void ChangeWrap(Boolean newAutoWrap, Boolean redraw);
- // Changes auto-wrapping behavior, redrawing if requested
-
- virtual void ReleaseText();
- // Releases the text by disposing of fDataHandle.
-
- virtual void SetJustification(short theJust, Boolean redraw);
- // Sets the justification of the text to theJust, redrawing if required.
-
- virtual void SetText(const CStr255& theText, Boolean redrawImmediately);
- // Sets the text to theText, redrawing if required.
-
- virtual void SetTextWithStrListID(ResNumber theStrListID, short theIndex, Boolean redraw);
- // Set fDataHandle to the string specified by theStrListID and theIndex and sets fStrListID
- // and fIndex accordingly.
-
- #if qDrag
- virtual void DoAddDragContent();
- // Install flavors in the current drag
- #endif // qDrag
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- CStringHandle fDataHandle; // A handle to the actual CString.
-
- ResNumber fStrListID; // ID of the CString list that the CString
- // is in.
-
- short fIndex; // Index number for the CString from the
- // above list.
-
- short fJust; // Jusitification of the text in the
- // field.
-
- Boolean fAutoWrap; // True to word wrap lines at the view
- // boundary otherwise lines wrap at
- // Carriage return.
-
- Boolean fEraseFirst; // control imaging of static text
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TEditText: Implements an edit text field.
- //----------------------------------------------------------------------------------------
-
- class TEditText : public TStaticText
- {
- MA_DECLARE_CLASS;
-
- public:
- TEditText();
- // Constructor
-
- void IEditText(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- short itsMaxChars);
- // Initialize the edit text item procedurally.
-
- virtual ~TEditText();
- // Un-installs the floating TEView, sets fTEView to NULL then calls Inherited::Free.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
- virtual void WriteSubViews(TStream* aStream);
-
-
- virtual void DoSubstitution(CStr255& theText);
- // Default is to do nothing.
-
- virtual void GetText(CStr255& theText);
- // If TEView not NULL then returns the extracted text, otherwise calls Inherited::GetText.
-
- virtual void ImageText(Ptr text,
- long length,
- const VRect& box,
- short just);
- // Sets up the text to the parameters passed. Text is drawn in a 'box' , the text
- // is 'length' long.
-
- virtual Boolean HandleMouseDown(const VPoint& theMouse,
- TToolboxEvent* event,
- CPoint hysteresis,
- EMouseDownType mouseDownType = kDragOrClick); // Override
-
- virtual void DoMouseCommand(VPoint& theMouse,
- TToolboxEvent* event,
- CPoint hysteresis); // Override
-
- virtual void BecameWindowTarget(); // Override
- // Overridden to install the "floating" TDialogTEView
-
- virtual void BecameTarget(); // Override
- // Overridden to make the "floating" TDialogTEView the target
-
- virtual void SetTargetSelection(Boolean redraw); // Override
- // Selects all the characters in this EditText
-
- virtual Boolean WantsToBeTarget(); // Override
-
- virtual Boolean IsTarget();
- // Returns true when this object (or its "floating" TEView) is the current target
-
- virtual void RestartEdit(const CStr255& restartText);
- // This method resets the text of the view, as well as selecting the text. We go
- // to some extra trouble to ensure that this method doesn't do any drawing,
- // defering to window update time. The reasoning is that this method usually gets
- // called right after displaying an alert. The alert may have obscured this view,
- // thus including it in the window's update region. If we drew in this method we
- // would get flashing as this view would get redraw at update time. Unfortunately
- // TextEdit isn't very cooperative so we set the clipping to an empty CRect to
- // ensure that TEActivate's drawing isn't seen.
-
- virtual void ChangeWrap(Boolean newAutoWrap, Boolean redraw);
- // Changes auto-wrapping behavior, redrawing if requested.Forwards into the
- // floating TE if necessary.
-
- virtual void SetJustification(short theJust, Boolean redraw);
- // Sets the justification of the text to theJust, redrawing is required.
-
- virtual void SetSelection(short selStart,
- short selEnd,
- Boolean redraw);
- // Sets the selection in the field starting at selStart and ending at selEnd,
- // redrawing if required.
-
- virtual void SetText(const CStr255& theText, Boolean redrawImmediately);
- // Sets the displayed text to theText, redrawing if required.
-
- virtual void StartEdit(Boolean selectChars);
- // Install the selection, revealing the selection if required.
-
- virtual void MakeVisible();
- // Reveal the EditText, if scrolled out of view
-
- virtual Boolean Deselect();
- // Valdates and and deselects the edit text, if possible
-
- virtual void StopEdit();
- // Extracts the CString from the TEView, then clears out the TEView before calling
- // this->SetText.
-
- virtual void InstallFloatingTEView(Boolean selectChars);
- // Attach the "floating" TDialogTEView to this EditText
-
- virtual void RemoveFloatingTEView();
- // Remove the "floating" TDialogTEView from this EditText.
-
- virtual TDialogTEView* GetTEView();
- // Returns a "floating" TDialogTEView to install in this EditText
-
- virtual void ReleaseTEView();
- // Returns the "floating" TDialogTEView to the server
-
- virtual long GetValidationError(); // Override
- // By default just returns true.
-
- virtual void ValidationFailed(long reason); // Override
- // Displays an alert when validation fails.
-
- virtual void GetDefaultCursorRegion(const VPoint& localPoint,
- RgnHandle cursorRegion); // Override
- // Sets the cursor region to the control area (i.e. including inset)
-
- #if qDrag
-
- //------------------------------------------------------------------------------------
- // Drag/Drop Support
- //------------------------------------------------------------------------------------
-
- virtual RgnHandle DoMakeDragCursorRegion(); // Override
- // Provide a drag test region in local coordinates.
-
- virtual Boolean WillDrag(const VPoint& theMouse, const RgnHandle dragCursorRegion); // Override
- // Return true if a mouse click at theMouse would begin a drag
-
- virtual short GetWillDragCursorID(); // Override
- // display quickdraw arrow cursor
-
- virtual short GetIsDraggingCursorID(); // Override
- // display quickdraw arrow cursor
-
- virtual void DoAddDragContent(); // Override
- // Add text content
-
- virtual Boolean WillAcceptDrop(CDragItemIterator& dragItemIterator); // Override
- // Return true if the drag contains a single text item
-
- virtual void DoDragEnter(); // Override
- // Become the current drop target. Install a floating text edit view
-
- virtual RgnHandle DoMakeDropHiliteRegion(); // Override
- // Create a local region that will represent the drop area
-
- virtual void DoDragWithin(const VPoint& localMouse); // Override
- // Tell the fTEView to manage mouse tracking during a drag.
-
- virtual void DoDragLeave(); // Override
- // Notify the TEView that the drag has left
-
- virtual TCommand* DoMakeDragDropCommand(CommandNumber itsCommandNumber,
- CDragItemIterator& dragItemIterator); // Override
- // Create a drag drop command.
-
- virtual void DoFulfillPromise(TDragItem* promisedItem); // Override
- // Provide promised flavor on demand
-
- #endif // qDrag
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- TDialogTEView* fTEView;
-
- ControlCharSet fControlChars; // Control chars accepted in text
-
- short fMaxChars;
- }; // class TEditText
-
-
- //----------------------------------------------------------------------------------------
- // TNumberText: This subclass of TEditText that allows the handling of integer numbers.
- // Range checking will be performed on the numbers entered to see if they are in the range
- // fMinimum to fMaximum.
- //----------------------------------------------------------------------------------------
-
- class TNumberText : public TEditText
- {
- MA_DECLARE_CLASS;
-
- public:
- TNumberText();
- // Constructor
- virtual ~TNumberText();
- // Destructor
-
- void INumberText(TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- long itsValue,
- long itsMinimum,
- long itsMaximum);
- // Initialize the number text item procedurally.
-
- //------------------------------------------------------------------------------------
- // Standard signature support.
- //------------------------------------------------------------------------------------
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
-
- virtual long GetValue();
- // Returns the current value by getting the CString and converting it to a number.
-
- virtual void SetValue(long newValue, Boolean redraw);
- // Sets the current value by converting the number to a CString and then calling SetText.
-
- virtual long GetValidationError();
- // Does a range check on the number and if it is out of range returns the
- // appropriate error code.
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- long fMinimum;
-
- long fMaximum;
- };
-
-
- //----------------------------------------------------------------------------------------
- // TDialogTEView: Provides a floating TEView that is placed over edit & number text fields
- // when entering text.
- //----------------------------------------------------------------------------------------
-
- class TDialogTEView : public TTEView
- {
- MA_DECLARE_CLASS;
-
- public:
-
- TDialogTEView();
- // Constructor
-
- void IDialogTEView(TDocument* itsDocument,
- TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHDeterminer,
- SizeDeterminer itsVDeterminer,
- const VRect& itsInset,
- const TextStyle& itsTextStyle,
- short itsJustification,
- Boolean itsStyleType,
- Boolean itsAutoWrap);
- // For Initialization of procedurally created TEView.
-
- virtual TObject* Clone();
- // calls Inherited::Clone and then clones owned objects.
-
- virtual ~TDialogTEView();
- // Free associated components and then free this.
-
- //------------------------------------------------------------------------------------
- // Stream I/O protocol support.
- //------------------------------------------------------------------------------------
-
- virtual void ReadFields(TStream* aStream);
-
- virtual void WriteFields(TStream* aStream);
-
- //------------------------------------------------------------------------------------
- // Commands and Menus
- //------------------------------------------------------------------------------------
-
- virtual void InstallEditText(TEditText* theEditText, Boolean selectChars);
- // Installs the EditText adding this as a subview to EditText, then gets the text
- // from the EditText item and installs it in this.
-
- virtual void ComputeFrame(VRect& newFrame);
- // accounts for case in which horizontal determiner is sizeVariable should be
- // added to TTEView !!!
-
- virtual void ResignedTarget(); // Override
-
- virtual long WillingToResignTarget(); // Override
- // !!!
-
- virtual void TargetValidationFailed(long reason); // Override
-
- virtual TEditText* GetEditText(); // override
- // Get the edit text view, if any, that owns this TE view.
-
- #if qDrag
-
- //------------------------------------------------------------------------------------
- // Drag and Drop support
- //------------------------------------------------------------------------------------
-
- Boolean WillDrag(const VPoint& localMouse, const RgnHandle dragCursorRegion); // override
-
- virtual TView* DoGetDragProxy();
-
- inline short GetLastDropCaretOffset() {return fLastCaretOffset;}
-
- #endif // qDrag
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- TEditText* fEditText; // The edit text field to which the
- // floating TEView is currently tied.
-
- TScroller* fScroller; // The scroller that I am in for
- // mouseability.
- };
-
-
- //----------------------------------------------------------------------------------------
- // TTargetBorderView
- //----------------------------------------------------------------------------------------
-
- class TTargetBorderView : public TView
- {
- MA_DECLARE_CLASS;
-
- public:
- TTargetBorderView();
- // Constructor
- virtual ~TTargetBorderView();
- // Destructor
-
- void ITargetBorderView(TDocument* itsDocument,
- TView* itsSuperView,
- const VPoint& itsLocation,
- const VPoint& itsSize,
- SizeDeterminer itsHSizeDet,
- SizeDeterminer itsVSizeDet,
- IDType itsTargetView);
- // Initialization method for TTargetBorderView
-
- virtual IDType GetStandardSignature(); // Override
- // Returns this class's standard signature.
-
- virtual void ReadFields(TStream* aStream);
- virtual void WriteFields(TStream* aStream);
- virtual void DoEvent(EventNumber eventNumber,
- TEventHandler* source,
- TEvent* event); // Override
- virtual void DoMouseCommand(VPoint& theMouse,
- TToolboxEvent* event,
- CPoint hysteresis); // Override
- virtual void ComputeBorderRegion(RgnHandle borderRegion);
- virtual void InvalidateBorderRegion();
- virtual void Draw(const VRect& area); // Override
- virtual void SetFrame(const VRect& newFrame, Boolean invalidate); // Override
-
- virtual Boolean ContainsTarget(TEventHandler *target);
- // return true if the relationship between this view and the target
- // determines that the border should be drawn
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- IDType fTargetView;
-
- };
-
- //----------------------------------------------------------------------------------------
- // TFloatingTEManager: Acts as a "server" for the "floating" TDialogTEViews installed in
- // EditTexts. A one-view cache is maintained
- //----------------------------------------------------------------------------------------
-
- class TFloatingTEManager : public TObject
- {
- MA_DECLARE_CLASS;
-
- public:
- TFloatingTEManager();
- // Constructor
-
- void IFloatingTEManager();
- // Initialization method for TFloatingTEManager .
-
- virtual ~TFloatingTEManager();
- // Frees the cache, and calls Inherited::Free.
-
- virtual TDialogTEView* AcquireFloatingTE();
- // Returns a "floating" TDialogTEView to install in an EditText. If the cache is
- // empty, one is created.
-
- virtual TDialogTEView* MakeDialogTEView();
-
- virtual void ReleaseFloatingTE(TDialogTEView* aDialogTEView);
- // Places the specified TDialogTEView in the cache, or frees it if the cache is
- // full.
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
- TDialogTEView* fCache;
- };
-
-
- //----------------------------------------------------------------------------------------
- // Externally available function declaration.
- //----------------------------------------------------------------------------------------
-
- extern void InitUDialog();
- // This routine must be called if UDialog is used so that all the necessary
- // initialization can be performed. Sets the global flag 'gUDialogInitialized' after
- // the initalization is performed.
-
- extern TDialogTEView* AcquireFloatingTEView();
- // Called by EditTexts to obtain a "floating" TDialogTEView to install. Procedural
- // interface to TFloatingTEManager::AcquireFloatingTE.
-
- extern void ReleaseFloatingTEView(TDialogTEView* aDialogTEView);
- // Called by EditTexts when deselecting. Procedural interface to
- // TFloatingTEManager::ReleaseFloatingTE.
-
- // extern void MAParamText(const CStr255& keyStr, const CStr255& valueStr);
- // // Used to create paramTxt items for a dialog. Builds an association with keyStr and
- // // valueStr. All instances of keyStr in the dialog will be replaced with valueStr when
- // // the dialog is displayed.
-
- // extern void MAReplaceText(CStr255& theText);
- // // If there are any param text items in the theText passed to this method then they
- // // are replaced with the appropriate values.
-
-
- //----------------------------------------------------------------------------------------
- // Externally available variable declarations.
- //----------------------------------------------------------------------------------------
-
- extern TFloatingTEManager* gFloatingTEManager;
-
- #endif // __UDIALOG__
-